package com.colza.forBase;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.DriverManager;

import com.mysql.jdbc.Driver;


/**
 * 
 * 
 * @author zou
 *	-Create connection = initialize connection and statement
 *  -Execute and show result =Statement.executequery()
 *  -Close connection = close()
 */
public class QueryConnection {
	private static final String BASE="basecolaza";
	private static final String HOST="jdbc:mysql://localhost/"+BASE;
	private static final String USER="root";
	private static final String PASS="";
	private Connection connection=null;
	static final String DRIVER="com.mysql.jdbc.Driver";
	private Statement stat;
	private ResultSet result;
	private boolean isConnect=false;
	
	private static final String SELECT_ALL="SELECT * FROM `resultat` WHERE 1";
	
	public QueryConnection(){
		super();

	}

	public static void main(String[] argv) {
		 
		System.out.println("-------- MySQL JDBC Connection Testing ------------");
	 
		try {
			Class.forName(DRIVER);
		} catch (ClassNotFoundException e) {
			System.out.println("Where is your MySQL JDBC Driver?");
			e.printStackTrace();
			return;
		}
	 
		System.out.println("MySQL JDBC Driver Registered!");
		Connection connection = null;
	 
		try {
			connection = DriverManager
			.getConnection(HOST,USER,PASS);
	 
		} catch (SQLException e) {
			System.out.println("Connection Failed! Check output console");
			e.printStackTrace();
			return;
		}
	 
		if (connection != null) {
			System.out.println("You made it, take control your database now!");
		} else {
			System.out.println("Failed to make connection!");
		}
	  }
	
}
